import Vue from "vue";
import VueRouter from "vue-router";
import Layout from "@/views/layout/App.vue";
import ArticleManage from "./articleManage";
import GoodsManage from "./goodsManage";
import UserManage from "./userManage";
import BannerManage from "./bannerManage";
import LogManage from "./logManage";
import CommentManage from "./commentManage";
import eChart from "./eChart";
import BlogManagement from "./blogManagement";
import chat from "./chat";

Vue.use(VueRouter);

const routes = [{
        path: "/home",
        component: Layout,
        name: "Dashboard",
        redirect: "/home",
        meta: {
            title: "后台管理系统"
        },
        children: [{
            path: "/home",
            name: "DashboardHome",
            meta: {
                title: "首页"
            },
            component: resolve => require(["@/views/home/Index.vue"], resolve)
        }]
    }, {
        path: '/comment',
        name: 'CommentManage',
        component: CommentManage
    },
    ArticleManage,
    BannerManage,
    GoodsManage,
    UserManage,
    LogManage,
    CommentManage,
    eChart,
    BlogManagement,
    chat,

    {
        path: "/",
        name: "Login",
        meta: {
            title: "后台登录",
            keepAlive: false
        },
        components: {
            blank: resolve => require(["@/views/login/Login.vue"], resolve)
        }
    },
    {
        path: '/webIndex',
        name: 'WebIndex',
        meta: {
            title: "商城首页",
            keepAlive: false
        },
        components: {
            blank: resolve => require(["@/views/webManage/Index.vue"], resolve)
        }
    }


];

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err);
};

const router = new VueRouter({
    routes
});

export default router;